<%@ page import="entity.Friend" %>
<%@ page import="java.util.List" %>
<%@ page import="entity.User" %><%--
  Created by IntelliJ IDEA.
  User: 林不清
  Date: 2020/12/11
  Time: 19:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>通讯录管理</title>
    <link rel="stylesheet" href="css/friend.css">
</head>
<body>
<%request.setCharacterEncoding("utf-8");%>
<%
    List<Friend> friends = (List<Friend>) request.getAttribute("friend_info");
    System.out.println(request.getAttribute("pageNow"));

//        System.out.println("index.jsp: friends: " + friends);
    if(friends != null){
%>
<div class="friend_container" >
    <a href="#" name="friend_info"></a>
    <div class="friend" style="font-size: 30px;margin-left: 40px;margin-top: 50px">
        <img src="img/contact.jpg" alt="" style="width: 90px;height: 90px;">
        <p style="float:right; margin-right:1100px;font-weight: bolder">通讯录</p>
    </div>
    <div class="friend_wrapper">
        <div>
            <a href="addfriends.jsp?method=add" target="main">添加联系人</a>
        </div>
        <div>
            <form action="friend.jhtml?method=find" method="post" name="findFriendsForm">
                <input type="text" name="findFriend" placeholder="请输入姓名">
                <input type="submit" value="查找">
            </form>
        </div>
        <table class="show_friend" border="1" cellspacing="0">
            <th>编号</th><th>姓名</th><th>性别</th><th>邮箱</th><th>号码</th><th>学校</th><th>操作</th>
            <%
                for(Friend f : friends){
            %>
            <tr>
                <td><%=f.getFid()%></td>
                <td><%=f.getFname()%></td>
                <td><%=f.getFsex()%></td>
                <td><%=f.getFemail()%></td>
                <td><%=f.getFphone()%></td>
                <td><%=f.getFschool()%></td>
                <td><a href="friendopt.jhtml?method=edit&id=<%=f.getFid()%>" target="main">编辑</a>&nbsp;<a href="friendopt.jhtml?id=<%=f.getFid()%>&method=del" target="main">删除</a></td>
            </tr>
            <%
                }
            %>
        </table>
        <%
            String isPage = (String) request.getAttribute("page");
            if (isPage == null || !isPage.equals("no")){%>
        <div style="margin-top: 20px; margin-left: 650px">
            <span>共有<%=request.getAttribute("allpage") %>页</span>
            <span style="margin-left:150px">第<%=request.getAttribute("pageNow")%>页</span>&nbsp;&nbsp;
            <a href="friend.jhtml?pageNow=1" >首页</a>
            <%if((int)request.getAttribute("pageNow")>1){
            %>
            <a href="friend.jhtml?pageNow=<%=(int)request.getAttribute("pageNow")-1%>">上一页</a>
            <%
                }
            %>
            <%
                if ((int) request.getAttribute("pageNow") < (int) request.getAttribute("allpage")) {
            %>
            <a href="friend.jhtml?pageNow=<%=(int)request.getAttribute("pageNow")+1%>">下一页</a>
            <%} %>
            <a href="friend.jhtml?pageNow=<%=(int)request.getAttribute("allpage")%>" >末页</a>

        </div>
    </div>
    <%}%>

</div>
    <%
        }
    %>

</div>

</body>
</html>
